#!/bin/sh

# Fix the setuid bits on our background tools
chown root:wheel /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/install_scripts
chmod u+s /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/install_scripts
chown root:wheel /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/remove_scripts
chmod u+s /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/remove_scripts
chown root:wheel /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/install_crontab
chmod u+s /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/install_crontab
chown root:wheel /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/manual_backup
chmod u+s /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/manual_backup
chown root:wheel /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/archive_table
chmod u+s /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/archive_table
chown root:wheel /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/abort_backup
chmod u+s /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/abort_backup

# Fix directory ownerships/permissions
chown root:admin /Library
chmod 775 /Library /Library/PreferencePanes /Library/PreferencePanes/DejaVu.prefPane
chmod 775 /Library/PreferencePanes/DejaVu.prefPane/Contents/Resources/*.scpt

# Make sure the pref panes cache gets updated
touch /Library/PreferencePanes

# Delete any existing scheduled backup scripts inside of /etc/periodic
rm -f /etc/periodic/daily/dejavu_daily.rb
rm -f /etc/periodic/daily/.lastbackup
rm -f /etc/periodic/weekly/dejavu_weekly.rb
rm -f /etc/periodic/weekly/.lastbackup
rm -f /etc/periodic/monthly/dejavu_monthly.rb
rm -f /etc/periodic/monthly/.lastbackup

# Give them a clue where to find Deja Vu
#open /Library/PreferencePanes/DejaVu.prefPane
